//
//  OrderNumModel.swift
//  Pods
//
//  Created by eme on 2017/3/23.
//
//

import Foundation
import SwiftyJSON
import ModelProtocol

class OrderNumModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kOrderNumOrderstatus5Key: String = "orderstatus5"
    internal let kOrderNumOrderstatus2Key: String = "orderstatus2"
    internal let kOrderNumOrderstatus0Key: String = "orderstatus0"
    internal let kOrderNumOrderstatus4Key: String = "orderstatus4"
    internal let kOrderNumOrderstatus8Key: String = "orderstatus8"
    internal let kOrderNumOrderstatus1Key: String = "orderstatus1"
    internal let kOrderNumOrderstatus3Key: String = "orderstatus3"
    internal let kOrderNumOrderstatus7Key: String = "orderstatus6"
    internal let kOrderNumMessagenumKey: String = "messagenum"
    
    
    // MARK: 属性
    var orderstatus5: Int!
    var orderstatus2: Int!
    var orderstatus0: Int!
    var orderstatus4: Int!
    var orderstatus8: Int!
    var orderstatus1: Int!
    var orderstatus3: Int!
    var orderstatus6: Int!
    var messagenum: Int!
    var message_Num:String!{
        get {
            if self.messagenum == 0{
                return ""
            }else{
                if self.messagenum >= 99{
                    return "\(99)+"
                }else{
                    return "\(messagenum!)"
                }
            }
        }
    }
    var dfk_Num:String{
        get{
            if self.orderstatus0 == 0{
                return ""
            }else{
                if self.orderstatus0 >= 99{
                    return "\(99)+"
                }else{
                    return "\(orderstatus0!)"
                }
                
            }
        }
        
    }
    var fh_Num:String{
        get{
            if self.orderstatus2 == 0{
                return ""
            }else{
                if self.orderstatus2 >= 99{
                    return "\(99)+"
                }else{
                    return "\(self.orderstatus2!)"
                }
            }
        }
    }
    var sh_Num:String{
        get{
            if orderstatus4 == 0{
                return ""
            }else{
                if self.orderstatus4 >= 99{
                    return "\(99)+"
                }else{
                    return "\(orderstatus4!)"
                }
            }
        }
    }
    var pj_Num:String{
        get{
            if self.orderstatus6 == 0{
                return ""
            }else{
                if self.orderstatus6 >= 99{
                    return "\(99)+"
                }else{
                    return "\(orderstatus6!)"
                }
            }
        }
    }
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        orderstatus5 = json[kOrderNumOrderstatus5Key].intValue
        orderstatus2 = json[kOrderNumOrderstatus2Key].intValue
        orderstatus0 = json[kOrderNumOrderstatus0Key].intValue
        orderstatus4 = json[kOrderNumOrderstatus4Key].intValue
        orderstatus8 = json[kOrderNumOrderstatus8Key].intValue
        orderstatus1 = json[kOrderNumOrderstatus1Key].intValue
        orderstatus3 = json[kOrderNumOrderstatus3Key].intValue
        orderstatus6 = json[kOrderNumOrderstatus7Key].intValue
        messagenum = json[kOrderNumMessagenumKey].intValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
            dictionary.updateValue(orderstatus5! as AnyObject, forKey: kOrderNumOrderstatus5Key)
        
            dictionary.updateValue(orderstatus2! as AnyObject, forKey: kOrderNumOrderstatus2Key)
        
            dictionary.updateValue(orderstatus0! as AnyObject, forKey: kOrderNumOrderstatus0Key)
        
            dictionary.updateValue(orderstatus4! as AnyObject, forKey: kOrderNumOrderstatus4Key)
        
            dictionary.updateValue(orderstatus8! as AnyObject, forKey: kOrderNumOrderstatus8Key)
        
            dictionary.updateValue(orderstatus1! as AnyObject, forKey: kOrderNumOrderstatus1Key)
        
            dictionary.updateValue(orderstatus3! as AnyObject, forKey: kOrderNumOrderstatus3Key)
        
            dictionary.updateValue(orderstatus6! as AnyObject, forKey: kOrderNumOrderstatus7Key)
        
            dictionary.updateValue(messagenum! as AnyObject, forKey: kOrderNumMessagenumKey)
        
        
        return dictionary
    }
    
    
}
